using System;
using RomanJendrusz.Amazon.ETL.Infrastructure.Bus;

namespace RomanJendrusz.Amazon.ETL.Messages
{
    public enum BookIdentifierType
    {
        ASIN,
        ISBN
    }

    public class GetBookDetailsRequest : AmazonRequest
    {
        private const string responseGroup = "ItemAttributes";

        public override string Destination
        {
            get { return AwsDestinations.ItemLookup; }
        }

        public override string ResponseGroup
        {
            get { return responseGroup; }
        }

        public string Identifier { get; set; }

        public BookIdentifierType IdentifierType { set; get; }

        public override string ToString()
        {
            return string.Format("Destination : {0} | ResponseGroup: {1} | Identifier : {2} | IdentifierType : {3}",
                                 Destination, ResponseGroup, Identifier, IdentifierType);
        }

        public bool Equals(GetBookDetailsRequest getBookDetailsRequest)
        {
            if (getBookDetailsRequest == null) return false;
            if (!base.Equals(getBookDetailsRequest)) return false;
            return Equals(Identifier, getBookDetailsRequest.Identifier) && Equals(IdentifierType, getBookDetailsRequest.IdentifierType);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj)) return true;
            return Equals(obj as GetBookDetailsRequest);
        }

        public override int GetHashCode()
        {
            int result = base.GetHashCode();
            result = 29*result + (Identifier != null ? Identifier.GetHashCode() : 0);
            result = 29*result + IdentifierType.GetHashCode();
            return result;
        }
    }
}